<?php
/**
 * Geneone: Content Management Framework
 * File: Upload File
 *
 * http://geneone.neondragon.net/
 *
 * @package Geneone
 * @author Khlo
 * @version 1.0
 * @copyright 2004-2006 Geneone Development Team
 */
 
class Gene_Special_Upload {
	/**
	 * Default Action
	 */
	function main() {
		$tpl =& Gene::getTemplate();
		$user =& Gene::getUser();
		
		$tpl->assign ("pagetitle", "Upload File");
		
		if (isset($_FILES['upfile'])) {
			require_once ("Gene/File/Common.php");
			$file =& Gene_File_Common::create($_FILES['upfile']['type']);
			if ($content = file_get_contents($_FILES['upfile']['tmp_name'])) {
				$file->setContent($content);
				$file->save();
						
				$id = $file->getId();
				
				$tpl->assign ("success", true);
				$tpl->assign ("fileid", $id);
			}
		}
		
		$tpl->assign("finalbody", $tpl->fetch("special/upload"));
	}
}
?>